home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / games / nhak_src.zip / U_INIT.C < prev    next >
C/C++ Source or Header  |  1993-03-16  |  19KB  |  697 lines

  1. /*    SCCS Id: @(#)u_init.c    3.0    89/11/15
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3. /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5. #include "hack.h"
  6.  
  7. struct trobj {
  8.     unsigned short int trotyp;
  9.     schar trspe;
  10.     char trolet;
  11.     Bitfield(trquan,6);
  12.     Bitfield(trknown,1);
  13.     Bitfield(trbless,2);
  14. };
  15.  
  16. static void FDECL(ini_inv, (struct trobj *));
  17. static void FDECL(knows_class,(CHAR_P));
  18. static int FDECL(role_index,(CHAR_P));
  19.  
  20. #define    UNDEF_TYP    0
  21. #define    UNDEF_SPE    '\177'
  22. #define    UNDEF_BLESS    2
  23.  
  24. const char *(roles[]) = {    /* must all have distinct first letter */
  25.             /* roles[2] and [6] are changed for females */
  26.             /* in all cases, the corresponding male and female */
  27.             /* roles must start with the same letter */
  28.     "Archeologist", "Barbarian", "Cave-man", "Elf", "Healer", "Knight",
  29.     "Priest", "Rogue", "Samurai", "Tourist", "Valkyrie", "Wizard"
  30. };
  31.  
  32. const char *pl_classes = "ABCEHKPRSTVW";
  33.  
  34. struct you zerou;
  35.  
  36. struct trobj Cave_man[] = {
  37. #define C_ARROWS    2
  38.     { CLUB, 1, WEAPON_SYM, 1, 1, UNDEF_BLESS },
  39.     { BOW, 1, WEAPON_SYM, 1, 1, UNDEF_BLESS },
  40.     { ARROW, 0, WEAPON_SYM, 25, 1, UNDEF_BLESS },    /* quan is variable */
  41.     { LEATHER_ARMOR, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
  42.     { 0, 0, 0, 0, 0, 0 }
  43. };
  44.  
  45. struct trobj Barbarian[] = {
  46.     { TWO_HANDED_SWORD, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
  47.     { AXE, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
  48.     { RING_MAIL, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
  49.     { FOOD_RATION, 0, FOOD_SYM, 1, 1, 0 },
  50.     { 0, 0, 0, 0, 0, 0 }
  51. };
  52.  
  53. struct trobj Knight[] = {
  54.     { LONG_SWORD, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
  55.     { SPEAR, 2, WEAPON_SYM, 1, 1, UNDEF_BLESS },
  56.     { RING_MAIL, 1, ARMOR_SYM, 1, 1, UNDEF_BLESS },
  57.     { HELMET, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
  58.     { SMALL_SHIELD, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
  59.     { LEATHER_GLOVES, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
  60.     { 0, 0, 0, 0, 0, 0 }
  61. };
  62.  
  63. struct trobj Elf[] = {
  64. #define E_ARROWS    2
  65. #define E_ARMOR        3
  66. #ifdef TOLKIEN
  67.     { ELVEN_SHORT_SWORD, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
  68.     { ELVEN_BOW, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
  69.     { ELVEN_ARROW, 0, WEAPON_SYM, 25, 1, UNDEF_BLESS },
  70.     { UNDEF_TYP, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
  71.     { LEMBAS_WAFER, 0, FOOD_SYM, 2, 1, 0 },
  72. #else
  73.     { SHORT_SWORD, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
  74.     { BOW, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
  75.     { ARROW, 0, WEAPON_SYM, 25, 1, UNDEF_BLESS },
  76.     { ELVEN_CLOAK, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
  77.     { FOOD_RATION, 0, FOOD_SYM, 2, 1, 0 },
  78. #endif
  79.     { 0, 0, 0, 0, 0, 0 }
  80. };
  81.  
  82. struct trobj Valkyrie[] = {
  83.     { LONG_SWORD, 1, WEAPON_SYM, 1, 1, UNDEF_BLESS },
  84.     { DAGGER, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
  85.     { SMALL_SHIELD, 3, ARMOR_SYM, 1, 1, UNDEF_BLESS },
  86.     { FOOD_RATION, 0, FOOD_SYM, 1, 1, 0 },
  87.     { 0, 0, 0, 0, 0, 0 }
  88. };
  89.  
  90. struct trobj Healer[] = {
  91.     { SCALPEL, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
  92.     { LEATHER_GLOVES, 1, ARMOR_SYM, 1, 1, UNDEF_BLESS },
  93.     { STETHOSCOPE, 0, TOOL_SYM, 1, 1, 0 },
  94.     { POT_HEALING, 0, POTION_SYM, 4, 1, UNDEF_BLESS },
  95.     { POT_EXTRA_HEALING, 0, POTION_SYM, 4, 1, UNDEF_BLESS },
  96.     { WAN_SLEEP, UNDEF_SPE, WAND_SYM, 1, 1, UNDEF_BLESS },
  97. #ifdef SPELLS
  98.     /* always blessed, so it's guaranteed readable */
  99.     { SPE_HEALING, 0, SPBOOK_SYM, 1, 1, 1 },
  100.     { SPE_EXTRA_HEALING, 0, SPBOOK_SYM, 1, 1, 1 },
  101. #endif
  102.     { APPLE, 0, FOOD_SYM, 5, 1, 0 },
  103.     { 0, 0, 0, 0, 0, 0 }
  104. };
  105.  
  106. struct trobj Archeologist[] = {
  107.     /* if adventure has a name...  idea from tan@uvm-gen */
  108.     { BULLWHIP, 2, WEAPON_SYM, 1, 1, UNDEF_BLESS },
  109.     { LEATHER_ARMOR, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
  110.     { FEDORA, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
  111.     { FOOD_RATION, 0, FOOD_SYM, 3, 1, 0 },
  112.     { PICK_AXE, UNDEF_SPE, TOOL_SYM, 1, 1, UNDEF_BLESS },
  113.     { TINNING_KIT, 0, TOOL_SYM, 1, 1, UNDEF_BLESS },
  114.     { SACK, 0, TOOL_SYM, 1, 0, 0 },
  115.     { 0, 0, 0, 0, 0, 0 }
  116. };
  117.  
  118. struct trobj Tinopener[] = {
  119.     { TIN_OPENER, 0, TOOL_SYM, 1, 1, 0 },
  120.     { 0, 0, 0, 0, 0, 0 }
  121. };
  122.  
  123. struct trobj Magicmarker[] = {
  124.     { MAGIC_MARKER, UNDEF_SPE, TOOL_SYM, 1, 1, 0 },
  125.     { 0, 0, 0, 0, 0, 0 }
  126. };
  127.  
  128. struct trobj Lamp[] = {
  129.     { LAMP, 5, TOOL_SYM, 1, 1, 0 },
  130.     { 0, 0, 0, 0, 0, 0 }
  131. };
  132.  
  133. #ifndef HARD
  134. struct trobj Saving[] = {
  135.     { AMULET_OF_LIFE_SAVING, 0, TOOL_SYM, 1, 1, 0 },
  136.     { 0, 0, 0, 0, 0, 0 }
  137. };
  138. #endif
  139.  
  140. #ifdef EXPLORE_MODE
  141. struct trobj Wishing[] = {
  142.     { WAN_WISHING, 3, WAND_SYM, 1, 1, 0 },
  143.     { 0, 0, 0, 0, 0, 0 }
  144. };
  145. #endif
  146.  
  147. #ifdef WALKIES
  148. struct trobj Leash[] = {
  149.     { LEASH, 0, TOOL_SYM, 1, 1, 0 },
  150.     { 0, 0, 0, 0, 0, 0 }
  151. };
  152. #endif
  153.  
  154. struct trobj Blindfold[] = {
  155.     { BLINDFOLD, 0, TOOL_SYM, 1, 1, 0 },
  156.     { 0, 0, 0, 0, 0, 0 }
  157. };
  158.  
  159. struct trobj Tourist[] = {
  160. #define    T_DARTS        0
  161.     { DART, 2, WEAPON_SYM, 25, 1, UNDEF_BLESS },    /* quan is variable */
  162.     { UNDEF_TYP, UNDEF_SPE, FOOD_SYM, 10, 1, 0 },
  163.     { POT_EXTRA_HEALING, 0, POTION_SYM, 2, 1, UNDEF_BLESS },
  164.     { SCR_MAGIC_MAPPING, 0, SCROLL_SYM, 4, 1, UNDEF_BLESS },
  165.     { EXPENSIVE_CAMERA, 0, TOOL_SYM, 1, 1, 0 },
  166. #ifdef SHIRT
  167.     { HAWAIIAN_SHIRT, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
  168. #endif
  169.     { CREDIT_CARD, 0, TOOL_SYM, 1, 1, 0 },
  170.     { 0, 0, 0, 0, 0, 0 }
  171. };
  172.  
  173. struct trobj Rogue[] = {
  174. #define R_DAGGERS    1
  175.     { SHORT_SWORD, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
  176.     { DAGGER, 0, WEAPON_SYM, 10, 1, 0 },    /* quan is variable */
  177.     { LEATHER_ARMOR, 1, ARMOR_SYM, 1, 1, UNDEF_BLESS },
  178.     { POT_SICKNESS, 0, POTION_SYM, 1, 1, 0 },
  179.     { LOCK_PICK, 9, TOOL_SYM, 1, 1, 0 },
  180.     { SACK, 0, TOOL_SYM, 1, 0, 0 },
  181.     { 0, 0, 0, 0, 0, 0 }
  182. };
  183.  
  184. struct trobj Wizard[] = {
  185. #define W_MULTSTART    2
  186. #ifdef SPELLS
  187. #  define W_MULTEND    6
  188. #else
  189. #  define W_MULTEND    5
  190. #endif
  191.     { ATHAME, 1, WEAPON_SYM, 1, 1, 1 },    /* for dealing with ghosts */
  192.     { CLOAK_OF_MAGIC_RESISTANCE, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
  193.     { UNDEF_TYP, UNDEF_SPE, WAND_SYM, 1, 1, UNDEF_BLESS },
  194.     { UNDEF_TYP, UNDEF_SPE, RING_SYM, 2, 1, UNDEF_BLESS },
  195.     { UNDEF_TYP, UNDEF_SPE, POTION_SYM, 3, 1, UNDEF_BLESS },
  196.     { UNDEF_TYP, UNDEF_SPE, SCROLL_SYM, 3, 1, UNDEF_BLESS },
  197. #ifdef SPELLS
  198.     { UNDEF_TYP, UNDEF_SPE, SPBOOK_SYM, 1, 1, UNDEF_BLESS },
  199. #endif
  200.     { 0, 0, 0, 0, 0, 0 }
  201. };
  202.  
  203. struct    trobj    Samurai[] = {
  204.     { KATANA, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },
  205.     { SHORT_SWORD, 0, WEAPON_SYM, 1, 1, UNDEF_BLESS },    /* the wakizashi */
  206.     { SHURIKEN, 0, WEAPON_SYM, 9, 1, UNDEF_BLESS },        /* quan is variable */
  207.     { SPLINT_MAIL, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
  208.     { FORTUNE_COOKIE, 0, FOOD_SYM, 3, 1, 0 },
  209.     { 0, 0, 0, 0, 0, 0 }
  210. };
  211.  
  212. struct    trobj    Priest[] = {
  213.     { MACE, 1, WEAPON_SYM, 1, 1, 1 },
  214.     { CHAIN_MAIL, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
  215.     { SMALL_SHIELD, 0, ARMOR_SYM, 1, 1, UNDEF_BLESS },
  216.     { POT_WATER, 0, POTION_SYM, 4, 1, 1 },    /* holy water */
  217.     { CLOVE_OF_GARLIC, 0, FOOD_SYM, 1, 1, 0 },
  218. #ifdef SPELLS
  219.     { UNDEF_TYP, UNDEF_SPE, SPBOOK_SYM, 2, 1, UNDEF_BLESS },
  220. #endif
  221.     { 0, 0, 0, 0, 0, 0 }
  222. };
  223.  
  224. static void
  225. knows_class(sym)
  226. register char sym;
  227. {
  228.     register unsigned ct;
  229.     for (ct = 1; ct <= NROFOBJECTS; ct++)
  230.         if (objects[ct].oc_olet == sym) {
  231.             makeknown(ct);
  232.             objects[ct].oc_descr = NULL;    /* not a "discovery" */
  233.         }
  234. }
  235.  
  236. static int
  237. role_index(pc)
  238. char pc;
  239. {
  240.     register const char *cp;
  241.  
  242.     if(cp = index(pl_classes, pc))
  243.         return(cp - pl_classes);
  244.     return(-1);
  245. }
  246.  
  247. void
  248. u_init()
  249. {
  250.     register int i;
  251.     char pick, pc;
  252. #ifdef __GNULINT__
  253.     pick = i = 0;    /* prevent "used before set" warnings */
  254. #endif
  255.     Printf("\nNetHack, Copyright 1985, 1986, 1987, 1988, 1989, 1990.");
  256.     Printf("\n         By Stichting Mathematisch Centrum and M. Stephenson.");
  257.     Printf("\n         See license for details.\n\n");
  258.  
  259.     if(flags.female)  {    /* should have been set in NETHACKOPTIONS */
  260.         roles[2] = "Cave-woman";
  261.         roles[6] = "Priestess";
  262.     }
  263.  
  264.     if(pc = pl_character[0]) {
  265.         if('a' <= pc && pc <= 'z') pc += 'A'-'a';
  266.         if((i = role_index(pc)) >= 0)
  267.             goto got_suffix;
  268.         Printf("\nUnknown role: %c\n", pc);
  269.         pl_character[0] = pc = 0;
  270.     }
  271.  
  272. #ifndef MACOS
  273.  
  274.     Printf("\nShall I pick a character for you? [Y,N, or Q(quit)] ");
  275.  
  276.     while(!index("yYnNqQ", (pick = readchar())) && !index(quitchars, pick))
  277.         bell();
  278.  
  279.     if(index(quitchars, pick)) pick = 'Y';
  280.     else if('a' <= pick && pick <= 'z') pick += 'A'-'a';
  281.  
  282.     Printf("%c\n", pick);        /* echo */
  283.  
  284.     if (pick == 'Q') {
  285.         clearlocks();
  286.         settty(NULL);
  287.         exit(0);
  288.     }
  289.  
  290.     if (pick == 'Y')
  291.         goto beginner;
  292.  
  293.     Printf("\nWhat kind of character are you:\n\n");
  294.     Printf("      %s,", An(roles[0]));
  295.     for(i = 1; i < SIZE(roles); i++) {
  296.         Printf(" %s", an(roles[i]));
  297.         if((((i + 1) % 4) == 0) && (i != SIZE(roles) -1)) 
  298.             Printf(",\n        ");
  299.         else if(i < SIZE(roles) - 2)    Printf(",");
  300.         if(i == SIZE(roles) - 2)    Printf(" or");
  301.     }
  302.     Printf("?\n         [");
  303.     for(i = 0; i < SIZE(roles); i++) Printf("%c,", pl_classes[i]);
  304.     Printf(" or Q] ");
  305.  
  306.     while(pc = readchar()) {
  307.         if('a' <= pc && pc <= 'z') pc += 'A'-'a';
  308.         if (pc == 'Q') {
  309.             clearlocks();
  310.             settty(NULL);
  311.             exit(0);
  312.         }
  313.         if((i = role_index(pc)) >= 0) {
  314.             Printf("%c\n", pc);    /* echo */
  315.             (void) fflush(stdout);    /* should be seen */
  316.             break;
  317.         }
  318.         if(pc == '\n') break;
  319.         bell();
  320.     }
  321.     if(pc == '\n')    pc = 0;
  322.  
  323. #else
  324.     flags.wantspace = FALSE;
  325. #endif /* MACOS */
  326.  
  327. beginner:
  328.     if(!pc) {
  329.         i = rn2(SIZE(roles));
  330.         pc = pl_classes[i];
  331.         Printf("\nThis game you will be %s.\n", an(roles[i]));
  332.         getret();
  333.         /* give him some feedback in case mklev takes much time */
  334.         (void) putchar('\n');
  335.         (void) fflush(stdout);
  336.     }
  337.  
  338. got_suffix:
  339.  
  340.     (void) strncpy(pl_character, roles[i], PL_CSIZ-1);
  341.     pl_character[PL_CSIZ-1] = 0;
  342.     flags.beginner = 1;
  343.     u = zerou;
  344.     u.usym = S_HUMAN;
  345.     u.umoved = FALSE;
  346.     u.ugrave_arise = -1;
  347.  
  348.     u.ulevel = 0;    /* set up some of the initial attributes */
  349.     u.uhp = u.uhpmax = newhp();
  350.     adjabil(0,1);
  351.     u.ulevel = 1;
  352.  
  353.     u.uluck  = u.moreluck = 0;
  354.     init_uhunger();
  355.     uarm = uarmc = uarmh = uarms = uarmg = uarmf =
  356. #ifdef SHIRT
  357.     uarmu =
  358. #endif
  359.     uwep = uball = uchain = uleft = uright = 0;
  360.  
  361. #ifdef SPELLS
  362.     u.uen = u.uenmax = 1;
  363.     for (i = 0; i <= MAXSPELL; i++) spl_book[i].sp_id = NO_SPELL;
  364. #endif
  365. #ifdef THEOLOGY
  366.     u.ublesscnt = 300;            /* no prayers just yet */
  367.     u.ublessed = 0;                /* not worthy yet */
  368.     u.ugangr   = 0;                /* gods not angry */
  369. #endif
  370. #if defined(THEOLOGY) && defined(ELBERETH)
  371.     u.uhand_of_elbereth = 0;
  372. #endif
  373. #ifdef MEDUSA
  374.     u.ukilled_medusa = 0;
  375. #endif
  376. #ifdef HARD
  377.     u.udemigod = u.udg_cnt = 0;        /* not a demi-god yet... */
  378. #endif
  379. #ifdef POLYSELF
  380.     u.umonnum = u.ulycn = -1;
  381.     u.mh = u.mhmax = u.mtimedone = 0;
  382.     set_uasmon();
  383. #endif
  384.     switch(pc) {
  385.     /* pc will always be in uppercase by this point */
  386.     case 'C':
  387.         Cave_man[C_ARROWS].trquan = 12 + rnd(30);
  388.         ini_inv(Cave_man);
  389.         break;
  390.     case 'T':
  391.         Tourist[T_DARTS].trquan = 20 + rnd(20);
  392.         u.ugold = u.ugold0 = rnd(1000);
  393.         ini_inv(Tourist);
  394.         if(!rn2(25)) ini_inv(Tinopener);
  395.         else if(!rn2(25)) ini_inv(Magicmarker);
  396. #ifdef WALKIES
  397.         else if(!rn2(25)) ini_inv(Leash);
  398. #endif
  399.         break;
  400.     case 'R':
  401.         Rogue[R_DAGGERS].trquan = 5 + rnd(10);
  402.         u.ugold = u.ugold0 = 0;
  403.         ini_inv(Rogue);
  404.         if(!rn2(5)) ini_inv(Blindfold);
  405.         makeknown(SACK);
  406.         break;
  407.     case 'W':
  408. #ifdef SPELLS
  409.         u.uen = u.uenmax += rn2(4);
  410. #endif
  411.         ini_inv(Wizard);
  412.         if(!rn2(5)) ini_inv(Magicmarker);
  413.         if(!rn2(5)) ini_inv(Blindfold);
  414.         break;
  415.     case 'A':
  416.         ini_inv(Archeologist);
  417.         if(!rn2(10)) ini_inv(Tinopener);
  418.         else if(!rn2(4)) ini_inv(Lamp);
  419.         else if(!rn2(10)) ini_inv(Magicmarker);
  420.         knows_class(GEM_SYM);
  421.         makeknown(SACK);
  422.         /* We can't set trknown for it, then it'd be "uncursed"
  423.          * sack...
  424.          */
  425.         break;
  426.     case 'E':
  427.         Elf[E_ARROWS].trquan = 15+rnd(20);
  428. #ifdef TOLKIEN
  429.         Elf[E_ARMOR].trotyp = ((rn2(100) >= 50)
  430.                  ? ELVEN_MITHRIL_COAT : ELVEN_CLOAK);
  431.             /* rn2(100) > 50 necessary because some random number
  432.              * generators are bad enough to seriously skew the
  433.              * results if we use rn2(2)...  --KAA
  434.              */
  435. #endif
  436.         ini_inv(Elf);
  437.         if(!rn2(5)) ini_inv(Blindfold);
  438.         else if(!rn2(6)) ini_inv(Lamp);
  439. #ifdef TOLKIEN
  440.         /* makeknown(ELVEN_SHORT_SWORD);
  441.          * no need to do this since the initial inventory contains one,
  442.          * so ini_inv already did it for us
  443.          */
  444.         objects[ELVEN_SHORT_SWORD].oc_descr = NULL;
  445.         /* makeknown(ELVEN_ARROW); */
  446.         objects[ELVEN_ARROW].oc_descr = NULL;
  447.         /* makeknown(ELVEN_BOW); */
  448.         objects[ELVEN_BOW].oc_descr = NULL;
  449.         makeknown(ELVEN_SPEAR);
  450.         objects[ELVEN_SPEAR].oc_descr = NULL;
  451.         makeknown(ELVEN_DAGGER);
  452.         objects[ELVEN_DAGGER].oc_descr = NULL;
  453.         makeknown(ELVEN_BROADSWORD);
  454.         objects[ELVEN_BROADSWORD].oc_descr = NULL;
  455. #endif
  456.         makeknown(ELVEN_CLOAK);
  457.         objects[ELVEN_CLOAK].oc_descr = NULL;
  458.         break;
  459.     case 'V':
  460.         flags.female = TRUE;
  461.         ini_inv(Valkyrie);
  462.         if(!rn2(6)) ini_inv(Lamp);
  463.         knows_class(WEAPON_SYM);
  464.         break;
  465.     case 'H':
  466.         u.ugold = u.ugold0 = rnd(1000)+1000;
  467.         ini_inv(Healer);
  468.         if(!rn2(25)) ini_inv(Lamp);
  469.         break;
  470.     case 'K':
  471.         ini_inv(Knight);
  472.         knows_class(WEAPON_SYM);
  473.         break;
  474.     case 'B':
  475.         ini_inv(Barbarian);
  476.         if(!rn2(6)) ini_inv(Lamp);
  477.         knows_class(WEAPON_SYM);
  478.         break;
  479.     case 'S':
  480.         ini_inv(Samurai);
  481.         if(!rn2(5)) ini_inv(Blindfold);
  482.         knows_class(WEAPON_SYM);
  483.         break;
  484.     case 'P':
  485. #ifdef SPELLS
  486.         u.uen = u.uenmax += rn2(4);
  487. #endif
  488.         ini_inv(Priest);
  489.         if(!rn2(10)) ini_inv(Magicmarker);
  490.         else if(!rn2(10)) ini_inv(Lamp);
  491.         break;
  492.  
  493.     default:    /* impossible */
  494.         break;
  495.     }
  496. #ifndef HARD
  497.     ini_inv(Saving);    /* give beginners an extra chance */
  498. #endif
  499. #ifdef EXPLORE_MODE
  500.     if (discover)
  501.         ini_inv(Wishing);
  502. #endif
  503.     find_ac();            /* get initial ac value */
  504.     init_attr((pick != 'Y') ? 75 : 77);    /* init attribute values */
  505.     max_rank_sz();            /* set max str size for class ranks */
  506. /*
  507.  *    Do we really need this?
  508.  */
  509.     for(i = 0; i < A_MAX; i++)
  510.         if(!rn2(20)) {
  511.         register int xd = rn2(7) - 2;    /* biased variation */
  512.         adjattrib(i, xd, TRUE);
  513.         if (ABASE(i) < AMAX(i)) AMAX(i) = ABASE(i);
  514.         }
  515.  
  516.     /* make sure he can carry all he has - especially for T's */
  517.     while(inv_weight() > 0)
  518.         adjattrib(A_STR, 1, TRUE);
  519.  
  520. #ifdef THEOLOGY
  521.     u.ualignbase[0] = u.ualignbase[1] = u.ualigntyp;
  522. #endif
  523. }
  524.  
  525. static void
  526. ini_inv(trop)
  527. register struct trobj *trop;
  528. {
  529.     struct obj *obj;
  530.     while(trop->trolet) {
  531.         boolean undefined = (trop->trotyp == UNDEF_TYP);
  532.  
  533.         if (!undefined)
  534.             obj = mksobj((int)trop->trotyp,FALSE);
  535.         else obj = mkobj(trop->trolet,FALSE);
  536.  
  537.         /* For random objects, do not create certain overly powerful
  538.          * items: wand of wishing, ring of levitation, or the
  539.          * polymorph/polymorph control combination.  Specific objects,
  540.          * i.e. the discovery wishing, are still OK.
  541.          * Also, don't get a couple of really useless items.  (Note:
  542.          * punishment isn't "useless".  Some players who start out with
  543.          * one will immediately read it and use the iron ball as a
  544.          * weapon.)
  545.          */
  546.         if (undefined) {
  547. #ifdef POLYSELF
  548.             static unsigned NEARDATA nocreate = STRANGE_OBJECT;
  549. #  ifdef SPELLS
  550.             static unsigned NEARDATA nocreate2 = STRANGE_OBJECT;
  551. #  endif
  552. #endif
  553.             static unsigned NEARDATA nocreate3 = STRANGE_OBJECT;
  554.  
  555.             while(obj->otyp == WAN_WISHING
  556. #ifdef POLYSELF
  557.                 || obj->otyp == nocreate
  558. #  ifdef SPELLS
  559.                 || obj->otyp == nocreate2
  560. #  endif
  561. #endif
  562.                 || obj->otyp == nocreate3
  563. #ifdef ELBERETH
  564.                 || obj->otyp == RIN_LEVITATION
  565. #endif
  566.                 /* 'useless' items */
  567.                 || obj->otyp == POT_HALLUCINATION
  568.                 || obj->otyp == SCR_AMNESIA
  569.                 || obj->otyp == SCR_FIRE
  570.                 || obj->otyp == RIN_AGGRAVATE_MONSTER
  571.                 || obj->otyp == RIN_HUNGER
  572.                 || obj->otyp == WAN_NOTHING
  573.                             ) {
  574.                 free((genericptr_t) obj);
  575.                 obj = mkobj(trop->trolet, FALSE);
  576.             }
  577.  
  578.             /* Don't start with +0 or negative rings */
  579.             if(objects[obj->otyp].oc_charged && obj->spe <= 0)
  580.                 obj->spe = rne(3);
  581.  
  582.             /* Heavily relies on the fact that 1) we create wands
  583.              * before rings, 2) that we create rings before
  584.              * spellbooks, and that 3) not more than 1 object of a
  585.              * particular symbol is to be prohibited.  (For more
  586.              * objects, we need more nocreate variables...)
  587.              */
  588. #ifdef POLYSELF
  589.             switch (obj->otyp) {
  590.                 case WAN_POLYMORPH:
  591.                 case RIN_POLYMORPH:
  592.                 nocreate = RIN_POLYMORPH_CONTROL;
  593.                 break;
  594.                 case RIN_POLYMORPH_CONTROL:
  595.                 nocreate = RIN_POLYMORPH;
  596. #  ifdef SPELLS
  597.                 nocreate2 = SPE_POLYMORPH;
  598. #  endif /* SPELLS */
  599.             }
  600. #endif /* POLYSELF */
  601.             /* Don't have 2 of the same ring */
  602.             if (obj->olet == RING_SYM)
  603.                 nocreate3 = obj->otyp;
  604.         }
  605.  
  606.         obj->bknown = trop->trknown;
  607.         if(objects[obj->otyp].oc_uses_known) obj->known = trop->trknown;
  608.         /* not obj->dknown = 1; - let him look at it at least once */
  609.         obj->cursed = 0;
  610.         if(obj->olet == TOOL_SYM){ /* problem with multiple tools */
  611.             obj->quan = 1;     /* might be > because of grenades */
  612.         }
  613.         if(obj->olet == WEAPON_SYM) {
  614.             obj->quan = trop->trquan;
  615.             trop->trquan = 1;
  616.         }
  617.         if(obj->olet == FOOD_SYM && undefined) {
  618.             obj->known = 1;
  619.             /* needed for tins and eggs; harmless otherwise */
  620.             obj->bknown = 1;
  621.         }
  622.         /*
  623.          * The below lines not needed because they don't correspond
  624.          * to any actual inventory; nobody gets random tools.
  625.         else if(obj->olet == TOOL_SYM && undefined) {
  626.             obj->bknown = (obj->otyp != BAG_OF_TRICKS
  627.                 && obj->otyp != SACK
  628.                 && obj->otyp != CHEST
  629.                 && obj->otyp != LARGE_BOX
  630.                 && obj->otyp != ICE_BOX);
  631.         }
  632.         */
  633.         if(trop->trspe != UNDEF_SPE)
  634.             obj->spe = trop->trspe;
  635.         if(trop->trbless != UNDEF_BLESS)
  636.             obj->blessed = trop->trbless;
  637.  
  638.         if (!Is_container(obj))
  639.             obj->owt = weight(obj);
  640.             /* defined after setting otyp+quan */
  641.         obj = addinv(obj);
  642.  
  643.         /* Make the type known if necessary */
  644.         if (objects[obj->otyp].oc_descr && obj->known)
  645.                 makeknown(obj->otyp);
  646.  
  647.         if(obj->olet == ARMOR_SYM){
  648.             if (is_shield(obj) && !uarms)
  649.                 setworn(obj, W_ARMS);
  650.             else if (is_helmet(obj) && !uarmh)
  651.                 setworn(obj, W_ARMH);
  652.             else if (is_gloves(obj) && !uarmg)
  653.                 setworn(obj, W_ARMG);
  654. #ifdef SHIRT
  655.             else if (obj->otyp == HAWAIIAN_SHIRT && !uarmu)
  656.                 setworn(obj, W_ARMU);
  657. #endif
  658.             else if (is_cloak(obj) && !uarmc)
  659.                 setworn(obj, W_ARMC);
  660.             else if (is_boots(obj) && !uarmf)
  661.                 setworn(obj, W_ARMF);
  662.             else if (!uarm)
  663.                 setworn(obj, W_ARM);
  664.         }
  665.         /* below changed by GAN 01/09/87 to allow wielding of
  666.          * pick-axe or can-opener if there is no weapon
  667.          */
  668.         if(obj->olet == WEAPON_SYM || obj->otyp == PICK_AXE ||
  669.            obj->otyp == TIN_OPENER)
  670.             if(!uwep) setuwep(obj);
  671. #ifndef PYRAMID_BUG
  672.         if(--trop->trquan) continue;    /* make a similar object */
  673. #else
  674.         if(trop->trquan) {        /* check if zero first */
  675.             --trop->trquan;
  676.             if(trop->trquan)
  677.                 continue;    /* make a similar object */
  678.         }
  679. #endif
  680.         trop++;
  681.     }
  682. }
  683.  
  684. void
  685. plnamesuffix() {
  686.     register char *p;
  687.     if(p = rindex(plname, '-')) {
  688.         *p = 0;
  689.         pl_character[0] = p[1];
  690.         pl_character[1] = 0;
  691.         if(!plname[0]) {
  692.             askname();
  693.             plnamesuffix();
  694.         }
  695.     }
  696. }
  697.